Skip to content

Fix for issue #58#60

Merged
MartinBraquet merged 1 commit into
CompassConnections:mainfrom
O-Bots:main
Jun 13, 2026
Merged

Fix for issue #58#60
MartinBraquet merged 1 commit into
CompassConnections:mainfrom
O-Bots:main

Conversation

@O-Bots

@O-Bots O-Bots commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Description

Added a func to return the users first name correctly when preceded by a prefix

Summary by CodeRabbit

  • New Features
    • Enhanced member name display in private chat headers with improved handling of various name formats.

@vercel

vercel Bot commented Jun 13, 2026

Copy link
Copy Markdown

@O-Bots is attempting to deploy a commit to the Compass Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

A helper function getFirstName is extracted to standardize first name extraction from full names, with special handling for names where the first token ends with a period. The private chat header member name rendering is updated to use this new utility instead of inline name splitting logic.

Changes

First name display helper

Layer / File(s) Summary
First name display helper definition and usage
web/pages/messages/[channelId].tsx
New getFirstName helper splits and trims names, returning the first token by default, but returning the first two tokens joined with space if the first token ends with a period and another part exists. Member header name rendering is updated to call this helper.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

Suggested reviewers

  • MartinBraquet
🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Fix for issue #58' is vague and generic, referring only to an issue number without describing the actual change made to the codebase. Revise the title to describe the specific change, such as 'Add getFirstName helper for correct user name display' or 'Extract first name from full names correctly'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@O-Bots O-Bots requested a review from MartinBraquet June 13, 2026 06:53

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
web/pages/messages/[channelId].tsx (1)

104-108: ⚡ Quick win

Consider moving getFirstName to a shared utility file.

The function is exported from a page file, which suggests it may be reused elsewhere. For better code organization and discoverability, consider moving this helper to a shared utility module (e.g., web/lib/utils/name.ts or common/util/name.ts).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/pages/messages/`[channelId].tsx around lines 104 - 108, Move the
getFirstName helper out of the page file into a shared utility module and import
it from there: create a new exported function getFirstName(name: string) with
the exact implementation, export it from the new util, then replace the local
implementation in web/pages/messages/[channelId].tsx with an import of
getFirstName; ensure the function signature and behavior remain identical and
update any references to use the new import.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/pages/messages/`[channelId].tsx:
- Around line 104-108: Add a docstring to the exported function getFirstName
explaining its purpose (returns the first name portion from a full name string),
describing the trimming/splitting behavior, and documenting the special-case
logic that if the first token ends with a period and there is more than one
token it returns the first two tokens joined (e.g., "J. R. Smith" -> "J. R.").
Keep the docstring concise, include parameter and return descriptions for name:
string and the returned string, and place it immediately above the getFirstName
function declaration.

---

Nitpick comments:
In `@web/pages/messages/`[channelId].tsx:
- Around line 104-108: Move the getFirstName helper out of the page file into a
shared utility module and import it from there: create a new exported function
getFirstName(name: string) with the exact implementation, export it from the new
util, then replace the local implementation in
web/pages/messages/[channelId].tsx with an import of getFirstName; ensure the
function signature and behavior remain identical and update any references to
use the new import.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 426a8522-ea3d-4e5e-8d30-3352d15fa802

📥 Commits

Reviewing files that changed from the base of the PR and between 8b93251 and 5c6d230.

📒 Files selected for processing (1)
  • web/pages/messages/[channelId].tsx

Comment on lines +104 to +108
export const getFirstName = (name: string) => {
const parts = name.trim().split(/\s+/)
const first = parts[0].endsWith('.') && parts.length > 1 ? parts.slice(0, 2).join(' ') : parts[0]
return first
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add docstring for the exported getFirstName function.

This exported function lacks a docstring explaining its purpose and the special period-handling logic. As per coding guidelines, all public functions should have docstrings.

📝 Suggested docstring
+/**
+ * Extracts the first name from a full name string.
+ * If the first token ends with a period (e.g., "Dr."), returns the first two tokens.
+ * `@param` name - The full name to parse
+ * `@returns` The first name or prefix + first name (e.g., "Dr. John")
+ */
 export const getFirstName = (name: string) => {
   const parts = name.trim().split(/\s+/)
   const first = parts[0].endsWith('.') && parts.length > 1 ? parts.slice(0, 2).join(' ') : parts[0]
   return first
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const getFirstName = (name: string) => {
const parts = name.trim().split(/\s+/)
const first = parts[0].endsWith('.') && parts.length > 1 ? parts.slice(0, 2).join(' ') : parts[0]
return first
}
/**
* Extracts the first name from a full name string.
* If the first token ends with a period (e.g., "Dr."), returns the first two tokens.
* `@param` name - The full name to parse
* `@returns` The first name or prefix + first name (e.g., "Dr. John")
*/
export const getFirstName = (name: string) => {
const parts = name.trim().split(/\s+/)
const first = parts[0].endsWith('.') && parts.length > 1 ? parts.slice(0, 2).join(' ') : parts[0]
return first
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/pages/messages/`[channelId].tsx around lines 104 - 108, Add a docstring
to the exported function getFirstName explaining its purpose (returns the first
name portion from a full name string), describing the trimming/splitting
behavior, and documenting the special-case logic that if the first token ends
with a period and there is more than one token it returns the first two tokens
joined (e.g., "J. R. Smith" -> "J. R."). Keep the docstring concise, include
parameter and return descriptions for name: string and the returned string, and
place it immediately above the getFirstName function declaration.

Source: Coding guidelines

@MartinBraquet MartinBraquet merged commit 6d2f5fc into CompassConnections:main Jun 13, 2026
4 of 5 checks passed
@MartinBraquet

Copy link
Copy Markdown
Member

Great, thanks!

@MartinBraquet

Copy link
Copy Markdown
Member

Fixes #58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants